﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using System.Web.Script.Services;
using Newtonsoft.Json;
using System.Data;
using System.Configuration;

namespace PromotionEngine
{
    public partial class ChangePassword : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        [WebMethod]
        [ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)]
        public static string ChangeUserPassword(string oldPassword, string newPassword)
        {
            string msg = string.Empty;
            Promotion pmt = new Promotion();
            int errMsg = pmt.ChangePassword(ConfigurationManager.AppSettings["DATABASE_NAME"].ToString(), HttpContext.Current.Session["LoginUserName"].ToString(),
                oldPassword, newPassword);
            return errMsg.ToString();
            //if (errMsg == -1)
            //{
            //    msg = "Old password is incorrect.";
            //}
            //else if (errMsg > 0)
            //{
            //    msg = "Password successfully changed.";
            //}
            //return JsonConvert.SerializeObject(msg);
        }
    }
}